home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / MacButtonEditor.cpp < prev    next >
Text File  |  1997-02-20  |  3KB  |  131 lines

  1. /*
  2.  *  File:       MacButtonEditor.h
  3.  *  Summary:       A view that knows how to edit a TMacButton.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     1/06/96    JDJ        Created
  12.  */
  13.  
  14. #include "MacButtonEditor.h"
  15.  
  16. #include <ZTextBox.h>
  17.  
  18.  
  19. // ===================================================================================
  20. //    class CEditMacButtonCommand
  21. // ===================================================================================
  22.  
  23. //---------------------------------------------------------------
  24. //
  25. // CEditMacButtonCommand::~CEditMacButtonCommand
  26. //
  27. //---------------------------------------------------------------
  28. CEditMacButtonCommand::~CEditMacButtonCommand()
  29. {
  30. }
  31.  
  32.  
  33. //---------------------------------------------------------------
  34. //
  35. // CEditMacButtonCommand::CEditMacButtonCommand
  36. //
  37. //---------------------------------------------------------------
  38. CEditMacButtonCommand::CEditMacButtonCommand(TMacButton* pane, const SMacButtonInfo& oldInfo, const SMacButtonInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  39. {
  40. }
  41.  
  42.  
  43. //---------------------------------------------------------------
  44. //
  45. // CEditMacButtonCommand::UpdatePane
  46. //
  47. //---------------------------------------------------------------
  48. void CEditMacButtonCommand::UpdatePane(const SMacButtonInfo& info)
  49. {
  50.     mPane->SetCommandKey(info.commandKey);
  51. }
  52.  
  53. #pragma mark -
  54.  
  55. // ===================================================================================
  56. //    CMacButtonEditor
  57. // ===================================================================================
  58.  
  59. static TReanimatorRegister<CMacButtonEditor> sMacButtonEditorRegistrar;
  60.  
  61. //---------------------------------------------------------------
  62. //
  63. // CMacButtonEditor::~CMacButtonEditor
  64. //
  65. //---------------------------------------------------------------
  66. CMacButtonEditor::~CMacButtonEditor()
  67. {
  68. }
  69.  
  70.  
  71. //---------------------------------------------------------------
  72. //
  73. // CMacButtonEditor::CMacButtonEditor
  74. //
  75. //---------------------------------------------------------------
  76. CMacButtonEditor::CMacButtonEditor(TView* superView) : Inherited(superView)
  77. {
  78. }
  79.  
  80.  
  81. //---------------------------------------------------------------
  82. //
  83. // CMacButtonEditor::Create                            [static]
  84. //
  85. //---------------------------------------------------------------
  86. MReanimatable* CMacButtonEditor::Create(MReanimatable* parent)
  87. {
  88.     return new CMacButtonEditor(dynamic_cast<TView*>(parent));
  89. }
  90.  
  91.  
  92. //---------------------------------------------------------------
  93. //
  94. // CMacButtonEditor::GetEditorInfo        
  95. //
  96. //---------------------------------------------------------------
  97. SMacButtonInfo CMacButtonEditor::GetEditorInfo() const
  98. {
  99.     SMacButtonInfo info;
  100.     
  101.     TTextBox* textBox = nil;
  102.         
  103.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Command Key"));
  104.     string text = textBox->GetText();
  105.     ASSERT(text.length() <= 1);
  106.     
  107.     if (text.length() == 1)
  108.         info.commandKey = text[0];
  109.     else
  110.         info.commandKey = ' ';
  111.     
  112.     return info;
  113. }
  114.  
  115.  
  116. //---------------------------------------------------------------
  117. //
  118. // CMacButtonEditor::SetEditorInfo
  119. //
  120. //---------------------------------------------------------------
  121. void CMacButtonEditor::SetEditorInfo(const SMacButtonInfo& info)
  122. {
  123.     TTextBox* textBox = nil;
  124.     
  125.     textBox = dynamic_cast<TTextBox*>(this->FindSubPane("Command Key"));
  126.     textBox->SetText(string(1, info.commandKey));
  127. }
  128.  
  129.  
  130.  
  131.